package com.admin.business.background.venusOaClockEquipment;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: pc打卡设备表
 * @create: 2023-10-31 16:47:32
 **/
@Service("venusOaClockEquipmentService")
@Slf4j
public class VenusOaClockEquipmentService{

    @Resource
    VenusOaClockEquipmentDao venusOaClockEquipmentDao;

    /**
     * 添加pc打卡设备表,获取id数据
     *
     * @param cdoRequest - id:主键
     *                   - orgId:总公司id
     *                   - org_id:公司id
     *                   - pro_id:项目id
     *                   - dept_id:部门id
     *                   - user_id:添加人id
     *                   - pc_name:电脑品牌
     *                   - pc_model:电脑型号
     *                   - pc_id:电脑编号
     *                   - unique_identifier:电脑唯一标识
     *                   - browser_type:浏览器类型
     *                   - ipv_four:ipv4 
     *                   - pc_position:电脑位置
     *                   - mac:mac
     *                   - ip_address:ip地址
     *                   - remark:备注
     *                   - by_user_id:操作人
     *                   - check_state:0.待确认 1.通过 2.拒绝 3.黑名单
     *                   - data_state:提示给申请人信息 0提示 1不提示
     *                   - update_time:修改时间
     *                   - begin_time:创建时间
     *                   - clock_uuid:打卡秘钥
     * @return
     * @author Ht
     * @create: 2023-10-31 16:47:32
     */
    @OpenApi
    public Return addVenusOaClockEquipment(CDO cdoRequest) {
        venusOaClockEquipmentDao.addVenusOaClockEquipment(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新pc打卡设备表数据
     *
     * @param cdoRequest - id:主键
     *                   - orgId:总公司id
     *                   - org_id:公司id
     *                   - pro_id:项目id
     *                   - dept_id:部门id
     *                   - user_id:添加人id
     *                   - pc_name:电脑品牌
     *                   - pc_model:电脑型号
     *                   - pc_id:电脑编号
     *                   - unique_identifier:电脑唯一标识
     *                   - browser_type:浏览器类型
     *                   - ipv_four:ipv4 
     *                   - pc_position:电脑位置
     *                   - mac:mac
     *                   - ip_address:ip地址
     *                   - remark:备注
     *                   - by_user_id:操作人
     *                   - check_state:0.待确认 1.通过 2.拒绝 3.黑名单
     *                   - data_state:提示给申请人信息 0提示 1不提示
     *                   - update_time:修改时间
     *                   - begin_time:创建时间
     *                   - clock_uuid:打卡秘钥
     * @return
     * @author Ht
     * @create: 2023-10-31 16:47:32
     */
    @OpenApi
    public Return updateVenusOaClockEquipmentById(CDO cdoRequest) {
        venusOaClockEquipmentDao.updateVenusOaClockEquipmentById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除pc打卡设备表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author Ht
     * @create: 2023-10-31 16:47:32
     */
    @OpenApi
    public Return deleteVenusOaClockEquipmentById(CDO cdoRequest){
        int count = venusOaClockEquipmentDao.deleteVenusOaClockEquipmentById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除pc打卡设备表数据
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-10-31 16:47:32
     */
    @OpenApi
    public Return deleteVenusOaClockEquipment(CDO cdoRequest) {
        int count = venusOaClockEquipmentDao.deleteVenusOaClockEquipment(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取pc打卡设备表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author Ht
     * @create: 2023-10-31 16:47:32
     */
    @OpenApi
    public Return getVenusOaClockEquipmentById(CDO cdoRequest) {
        CDO cdoMapperResult = venusOaClockEquipmentDao.getVenusOaClockEquipmentById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取pc打卡设备表数据列表
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-10-31 16:47:32
     */
    @OpenApi
    public Return getVenusOaClockEquipmentListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaClockEquipmentDao.getVenusOaClockEquipmentListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取pc打卡设备表数据列表
     *
     * @param cdoRequest - id:主键
     * @return
     * @author Ht
     * @create: 2023-10-31 16:47:32
     */
    @OpenApi
    public Return getVenusOaClockEquipmentListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaClockEquipmentDao.getVenusOaClockEquipmentListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
        return Return.valueOf(cdoResult);
    }
}
